package com.fr.base.core.serializable;

import com.fr.base.xml.BaseXMLUtils;
import java.awt.Image;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class ImageSerializable
  implements Serializable
{
  private transient Image image;

  public ImageSerializable(Image paramImage)
  {
    this.image = paramImage;
  }

  public Image getImage()
  {
    return this.image;
  }

  private void readObject(ObjectInputStream paramObjectInputStream)
    throws ClassNotFoundException, IOException
  {
    paramObjectInputStream.defaultReadObject();
    byte[] arrayOfByte = (byte[])paramObjectInputStream.readObject();
    if (arrayOfByte != null)
    {
      int i = paramObjectInputStream.readInt();
      int j = paramObjectInputStream.readInt();
      if ((i > 0) && (j > 0))
        this.image = BaseXMLUtils.decodeImage(i, j, arrayOfByte);
    }
  }

  private void writeObject(ObjectOutputStream paramObjectOutputStream)
    throws IOException
  {
    paramObjectOutputStream.defaultWriteObject();
    Object localObject = (this.image != null) ? BaseXMLUtils.encodeImage(this.image) : null;
    paramObjectOutputStream.writeObject(localObject);
    if (localObject != null)
    {
      paramObjectOutputStream.writeInt(this.image.getWidth(null));
      paramObjectOutputStream.writeInt(this.image.getHeight(null));
    }
  }
}